package com.everyday.practice.algorithm;

/**
 * @description: 237. 删除链表中的节点
 * @author: leon
 * @time: 2021/3/30 15:52
 */
public class Title237 {
    public static void main(String[] args) {
        ListNode node = new ListNode(1);
        node.next = new ListNode(2);
        node.next.next = new ListNode(3);
        node.next.next.next = new ListNode(4);
        deleteNode(node, 1);
        System.out.println("a");
    }

    public static void deleteNode(ListNode node, Integer v) {
        if (node.val == v) {
            node.val = node.next.val;
            node.next = node.next.next;
            return;
        } else if (node.next.val == v) {
            node.next = null;
        } else {
            deleteNode(node.next, v);
        }
    }

    public static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}
